/**
 * author wijnand.schepens@hogent.be
 * 
 */

package org.jfonia.assets.fonts;

import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

public class TextGlyph implements Glyph {

    private Graphics2D g;
    private float size;

    public TextGlyph(Graphics2D g, Font font, String code) {
        this.g = g;
        this.code = code;
        this.font = font;
        bounds = FontMeasurer.getBounds2D(g, font, code);
    }

    public void setSize(float size) {
        this.size = size;
        font = font.deriveFont(size);
        bounds = FontMeasurer.getBounds2D(g, font, code);
    }
	
	public void paint(Graphics2D g, double x, double y)
	{
		g.setFont(font);
		g.drawString(code, (float)x, (float)y);
	}
	
	public Rectangle2D getBounds() 
	{ 
		return bounds; 
	} 
	
	private Font        font;
	private String      code;
	private Rectangle2D bounds;
}
